package com.it.myh;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @Description: // 类说明，在创建类时要填写
 * @ClassName: Ev_0220_01    // 类名，会自动填充
 * @Author: MYH          // 创建者
 * @Date: 2023/2/20 9:53   // 时间
 * @Version: 1.0     // 版本
 */
public class Ev_0220_01 {

    public static void main(String[] args) {
        Map<String, Integer> map = new HashMap<>();
        map.put("aa",123);
        map.put("bb",456);
        map.put("cc",789);
        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        System.out.println("========遍历所有的键值对========");
        for (Map.Entry<String, Integer> entry : entries) {
            System.out.println(entry);
            System.out.println(entry.getKey());
            }
        System.out.println("============遍历所有的key============");
        Set<String> strings = map.keySet();
        for (String string : strings) {
            System.out.println(string);
        }
        System.out.println("============遍历所有的value============");
        Collection<Integer> values = map.values();
        for (Integer value : values) {
            System.out.println(value);
        }
        System.out.println("===========直接输出=================");
        System.out.println(map);
    }
}
